﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="wfManageBA.aspx.cs" Inherits="Dragon.wfManageBA" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">
    <title></title>
    <style type="text/css">
        .auto-style1 {
            width: 100%;
        }
        .auto-style2 {
        }
        .auto-style5 {
            width: 100px;
            height: 26px;
        }
        .auto-style6 {
            width: 150px;
            height: 26px;
        }
        </style>
</head>
<body>    
    <form id="form1" runat="server" style="background-image: url('Picture/background-clouds.jpg'); color: #000080;">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div id="ManageBAForm">
            <table>
                <tr>
                    <td id="SearchForm" style="border: thin ridge #000080; width: 860px; height:600px; float:left; margin-bottom:0px; overflow:hidden">
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                            <ContentTemplate>  
                        <table class="auto-style1">                                          
                            <tr>
                                <td class="auto-style5" style="width: 90px; color: #000080;">Tỉnh thành
                                </td>
                                <td class="auto-style6" style="width: 140px">
                                    <asp:DropDownList ID="ddlProvince" runat="server" DataSourceID="sdsProvince" DataTextField="Name" DataValueField="Code" Width="100%" 
                                        OnDataBound="ddlProvince_DataBound" ForeColor="#000099" AutoPostBack="True">
                                    </asp:DropDownList>
                                </td>
                                <td class="auto-style5" style="width: 90px; color: #000080;">Tổ trưởng
                                </td>
                                <td class="auto-style6" style="width: 140px">
                                    <asp:DropDownList ID="ddlBAS" runat="server" DataSourceID="sdsBAS" DataTextField="Name" DataValueField="Code" Width="100%" 
                                        OnDataBound="ddlBAS_DataBound" ForeColor="#000099" AutoPostBack="True">
                                    </asp:DropDownList>
                                </td>
                                <td class="auto-style5"style="width: 90px; color: #000080;">Nhóm BA
                                </td>
                                <td class="auto-style6"style="width: 140px">
                                    <asp:DropDownList ID="ddlBAGroup" runat="server" DataSourceID="sdsBAGroup" DataTextField="Name" DataValueField="Code" Width="100%" 
                                        OnDataBound="ddlBAGroup_DataBound" ForeColor="#000099" AutoPostBack="True">
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td class="auto-style2"style="width: 90px; color: #000080;">Trạng thái
                                </td>
                                <td style="width: 140px">
                                    <asp:DropDownList ID="ddlBAStatus" runat="server" DataSourceID="sdsBAStatus" DataTextField="Name" DataValueField="Code" Width="100%" 
                                        OnDataBound="ddlBAStatus_DataBound" ForeColor="#000099" AutoPostBack="True">
                                    </asp:DropDownList>
                                </td>
                                <td class="auto-style2"style="width: 90px; color: #000080;">SMS
                                </td>
                                <td style="width: 140px">
                                    <asp:DropDownList ID="ddlSMSStatus" runat="server" Width="100%" DataSourceID="sdsBASMSStatus" DataTextField="Name" DataValueField="Code" 
                                        OnDataBound="ddlSMSStatus_DataBound" ForeColor="#000099" AutoPostBack="True">
                                    </asp:DropDownList>
                                </td>
                                <td class="auto-style2"style="width: 90px; color: #000080;">Điểm bán
                                </td>
                                <td style="width: 140px">
                                    <asp:TextBox ID="txtCustomer" runat="server" Width="97%" AutoPostBack="True" ForeColor="#000099" OnTextChanged="txtCustomer_TextChanged"></asp:TextBox>
                                </td>
                            </tr> 
                            <tr>                                  
                                <td class="auto-style2"style="width: 100px; text-align: center;" colspan="4">
                                    <asp:Label ID="lblInfo" runat="server" ForeColor="#000099" style="font-weight: 700" Width="100%"></asp:Label>
                                </td>
                                <td class="auto-style2"style="width: 460px; text-align: center;" colspan="2">
                                    <asp:LinkButton ID="ExportData" runat="server" ForeColor="#000099" style="font-weight: 700" 
                                        OnClick="ExportData_Click">BA có sản lượng trong 45 ngày</asp:LinkButton>
                                </td>
                            </tr>
                            <tr>                
                                <td class="auto-style2" colspan="6" style="height: 500px; vertical-align:top">
                                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AllowSorting="True" 
                                        CellPadding="4" DataKeyNames="Code" PageSize="16" Width="100%" BackColor="White" BorderColor="#3366CC" 
                                        BorderStyle="None" BorderWidth="1px" DataSourceID="sdsBAList" 
                                        ShowHeaderWhenEmpty="True" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" AllowPaging="True">
                                        <Columns>
                                            <asp:CommandField ShowSelectButton="True" SelectText=">>>" />

                                            <asp:TemplateField HeaderText="Code" SortExpression="Code" Visible="False">                                       
                                                <ItemStyle Width="100px" />
                                            </asp:TemplateField>

                                            <asp:TemplateField ControlStyle-Width="90px" HeaderText="Province" SortExpression="Province">                                               
                                                <HeaderTemplate>
                                                    <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Sort" CommandArgument="Province"
                                                        Font-Bold="True" ForeColor="White">Tỉnh thành</asp:LinkButton>
                                                    <br />
                                                    <asp:TextBox ID="txtProvince" AutoPostBack="true" runat="server" Width="80px" OnTextChanged="txtFilter_TextChanged"></asp:TextBox>
                                                </HeaderTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("Province") %>'></asp:Label>
                                                </ItemTemplate>                                                
                                                <ControlStyle Width="90px" />
                                            </asp:TemplateField>

                                            <asp:TemplateField ControlStyle-Width="150px" HeaderText="BAS" SortExpression="BAS">                                                
                                                <HeaderTemplate>
                                                    <asp:LinkButton ID="LinkButton3" runat="server" CommandName="Sort" CommandArgument="BAS"
                                                        Font-Bold="True" ForeColor="White">Tổ trưởng</asp:LinkButton>
                                                    <br />
                                                    <asp:TextBox ID="txtBAS" AutoPostBack="true" runat="server" Width="140px" OnTextChanged="txtFilter_TextChanged"></asp:TextBox>
                                                </HeaderTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("BAS") %>'></asp:Label>
                                                </ItemTemplate>                                                
                                                <ControlStyle Width="150px" />
                                            </asp:TemplateField>

                                            <asp:TemplateField ControlStyle-Width="80px" HeaderText="CodeNS" SortExpression="CodeNS">                                           
                                                <HeaderTemplate>
                                                    <asp:LinkButton ID="LinkButton4" runat="server" CommandName="Sort" CommandArgument="CodeNS"
                                                        Font-Bold="True" ForeColor="White">Mã NV</asp:LinkButton>
                                                    <br />
                                                    <asp:TextBox ID="txtCodeNS" AutoPostBack="true" runat="server" Width="70px" OnTextChanged="txtFilter_TextChanged"></asp:TextBox>
                                                </HeaderTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label5" runat="server" Text='<%# Bind("CodeNS") %>'></asp:Label>
                                                </ItemTemplate>                                                
                                                <ControlStyle Width="80px" />
                                            </asp:TemplateField>

                                            <asp:TemplateField HeaderText="Name" SortExpression="Name">                                                
                                                <HeaderTemplate>
                                                    <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Sort" CommandArgument="Name" 
                                                        Font-Bold="True" ForeColor="White">Tên NV</asp:LinkButton>
                                                    <br />                                                  
                                                    <asp:TextBox ID="txtName" AutoPostBack="true" runat="server" Width="180px" OnTextChanged="txtFilter_TextChanged"></asp:TextBox>
                                                </HeaderTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
                                                </ItemTemplate>                                                
                                                <ControlStyle Width="190px" />
                                            </asp:TemplateField>

                                            <asp:TemplateField HeaderText="Phone" SortExpression="Phone">                                               
                                                <HeaderTemplate>
                                                    <asp:LinkButton ID="LinkButton5" runat="server" CommandName="Sort" CommandArgument="Phone"
                                                        Font-Bold="True" ForeColor="White">Số ĐT</asp:LinkButton>
                                                    <br />
                                                    <asp:TextBox ID="txtPhone" AutoPostBack="true" runat="server" Width="90px" OnTextChanged="txtFilter_TextChanged"></asp:TextBox>
                                                </HeaderTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label6" runat="server" Text='<%# Bind("Phone") %>'></asp:Label>
                                                </ItemTemplate>                                                
                                                <ControlStyle Width="100px" />
                                            </asp:TemplateField>

                                            <asp:TemplateField ControlStyle-Width="80px" HeaderText="BAGroup" SortExpression="BAGroup">                                                
                                                <HeaderTemplate>
                                                    <asp:LinkButton ID="LinkButton6" runat="server" CommandName="Sort" CommandArgument="BAGroup"
                                                        Font-Bold="True" ForeColor="White">Nhóm BA</asp:LinkButton>
                                                    <br />
                                                    <asp:TextBox ID="txtBAGroup" AutoPostBack="true" runat="server" Width="70px" OnTextChanged="txtFilter_TextChanged"></asp:TextBox>
                                                </HeaderTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label7" runat="server" Text='<%# Bind("BAGroup") %>'></asp:Label>
                                                </ItemTemplate>                                                
                                                <ControlStyle Width="80px" />
                                            </asp:TemplateField>

                                            <asp:TemplateField ControlStyle-Width="60px" HeaderText="BAStatus" SortExpression="BAStatus">                                                
                                                <HeaderTemplate>
                                                    <asp:LinkButton ID="LinkButton7" runat="server" CommandName="Sort" CommandArgument="BAStatus"
                                                        Font-Bold="True" ForeColor="White">Tr.thái</asp:LinkButton>
                                                    <br />
                                                    <asp:TextBox ID="txtBAStatus" AutoPostBack="true" runat="server" Width="50px" OnTextChanged="txtFilter_TextChanged"></asp:TextBox>
                                                </HeaderTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label8" runat="server" Text='<%# Bind("BAStatus") %>'></asp:Label>
                                                </ItemTemplate>                                                
                                                <ControlStyle Width="60px" />
                                            </asp:TemplateField>
                                        </Columns>
                                        <EmptyDataTemplate>
                                            Không có dữ liệu. Vui lòng chọn tiêu chí khác!
                                        </EmptyDataTemplate>
                                        <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
                                        <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="#CCCCFF" />
                                        <PagerSettings PageButtonCount="16" Mode="NumericFirstLast" FirstPageText="Trang đầu" LastPageText="Trang cuối" NextPageText="" PreviousPageText="" />
                                        <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" Width="50%" />                                   
                                        <RowStyle BackColor="White" ForeColor="#003399" />
                                        <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
                                        <SortedAscendingCellStyle BackColor="#EDF6F6" />
                                        <SortedAscendingHeaderStyle BackColor="#0D4AC4" />
                                        <SortedDescendingCellStyle BackColor="#D6DFDF" />
                                        <SortedDescendingHeaderStyle BackColor="#002876" />                                        
                                    </asp:GridView>
                                </td>                   
                            </tr>
                        </table>                  
                    </ContentTemplate>
                        </asp:UpdatePanel>
                    </td>        
                    <td id="UpdateForm" style="border: thin ridge #000080; height:600px; vertical-align:top; margin-bottom:0px; overflow:hidden">
                        <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <asp:Label ID="lblUpdateInfo" runat="server" ForeColor="Maroon" style="font-weight: 700; text-align:center" Width="100%"></asp:Label>                          
                            <asp:FormView ID="fvBADetail" runat="server" DataKeyNames="Code" DataSourceID="sdsBADetail" DefaultMode="Edit" CellSpacing="3" OnItemUpdated="fvBADetail_ItemUpdated">
                                <EditItemTemplate>
                                <asp:Label ID="CodeLabel1" runat="server" Text='<%# Eval("Code") %>' Visible="false"/>
                                <tr>       
                                    <td style="width:85px">Mã NS</td>
                                    <td style="width:125px">
                                        <asp:TextBox ID="CodeNSTextBox" runat="server" Text='<%# Bind("CodeNS") %>' Width="125px" 
                                            ForeColor="Red" Font-Bold="True" Font-Size="Large" />
                                    </td>
                                    <td style="width:85px">Nhóm BA</td>
                                    <td style="width:125px">
                                        <asp:DropDownList ID="BAGroupDropDownList" runat="server" DataSourceID="sdsBAGroup" DataTextField="Name" DataValueField="Code"
                                            SelectedValue = '<%# Bind("BAGroup") %>' Width="125px" ForeColor="#000099" AppendDataBoundItems="True">
                                            <asp:ListItem Selected="True" Value="">-----------------------</asp:ListItem>
                                        </asp:DropDownList>   
                                    </td>
                                </tr>                           
                            
                                <tr>       
                                    <td style="width:85px">Tên</td>
                                    <td style="width:350px;" colspan="3">
                                        <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' Width="99%" 
                                            ForeColor="Red" Font-Bold="True" Font-Size="Large" />
                                    </td>                                
                                </tr>                                

                                <tr>                                
                                    <td style="width:85px">BAS</td>
                                    <td style="width:350px;" colspan="3">
                                         <asp:DropDownList ID="ddlBASName" runat="server" DataSourceID="sdsBASAll" DataTextField="Name" DataValueField="Code"
                                          SelectedValue = '<%# Bind("BAS") %>' Width="350px" ForeColor="#000099" AppendDataBoundItems="True">
                                            <asp:ListItem Selected="True" Value="">-----------------------</asp:ListItem>
                                        </asp:DropDownList>    
                                    </td>
                                </tr>                               
                            
                                <tr>
                                    <td style="width:85px">Số ĐT</td>
                                    <td style="width:125px">
                                        <asp:TextBox ID="PhoneTextBox" runat="server" Text='<%# Bind("Phone") %>' Width="95%" ForeColor="#000099" />
                                    </td>

                                    <td style="width:85px">Nhãn hàng</td>
                                    <td style="width:125px">                                        
                                       <asp:DropDownList ID="BrandDropDownList" runat="server" DataSourceID="sdsBrand" DataTextField="Name" DataValueField="Code"
                                          SelectedValue = '<%# Bind("Brand") %>' Width="125px" ForeColor="#000099" AppendDataBoundItems="True">
                                            <asp:ListItem Selected="True" Value="">-----------------------</asp:ListItem>
                                        </asp:DropDownList>  
                                    </td>
                                </tr>
                            
                                <tr>
                                    <td style="width:85px">Hồ sơ</td>
                                    <td style="width:125px">                                        
                                       <asp:DropDownList ID="ProfileStatusDropDownList" runat="server" DataSourceID="sdsProfileStatus" DataTextField="Name" 
                                            DataValueField="Code" SelectedValue = '<%# Bind("ProfileStatus") %>' Width="125px" ForeColor="#000099" AppendDataBoundItems="True">
                                            <asp:ListItem Selected="True" Value="">-----------------------</asp:ListItem>
                                        </asp:DropDownList>
                                    </td>
                                                               
                                    <td style="width:85px">MST</td>
                                    <td style="width:125px">
                                        <asp:TextBox ID="TaxCodeTextBox" runat="server" Text='<%# Bind("TaxCode") %>' Width="95%" ForeColor="#000099" />
                                    </td>
                                </tr>                           

                                <tr>
                                    <td style="width:85px">Ngày sinh</td>
                                    <td style="width:125px">                                  
                                        <asp:TextBox ID="DOBTextBox" runat="server" Text='<%# Bind("DOB", "{0:MM/dd/yyyy}")%>' Width="95%" ForeColor="#000099"/>
                                        <cc1:CalendarExtender ID="DOBTextBox_CalendarExtender" runat="server" BehaviorID="DOBTextBox_CalendarExtender" 
                                            TargetControlID="DOBTextBox" Format="MM/dd/yyyy" />
                                    </td>  
                                
                                    <td style="width:85px">Dân tộc</td>
                                    <td style="width:125px">                                        
                                      <asp:DropDownList ID="FolkDropDownList" runat="server" DataSourceID="sdsFolk" DataTextField="Name" 
                                            DataValueField="Code" SelectedValue = '<%# Bind("Folk") %>' Width="125px" ForeColor="#000099" AppendDataBoundItems="True">
                                            <asp:ListItem Selected="True" Value="">-----------------------</asp:ListItem>
                                        </asp:DropDownList>
                                    </td>                                
                                </tr>

                                <tr>
                                    <td style="width:85px">Hộ khẩu</td>
                                    <td style="width:350px;" colspan="3">
                                            <asp:TextBox ID="ResidentAddressTextBox" runat="server" Text='<%# Bind("ResidentAddress") %>' Width="98.5%" ForeColor="#000099" />
                                    </td>
                                </tr>

                                <tr>                               
                                    <td style="width:85px">Quốc tịch</td>
                                    <td style="width:125px">                                        
                                       <asp:DropDownList ID="NationalityDropDownList" runat="server" DataSourceID="sdsNationality" DataTextField="Name" 
                                            DataValueField="Code" SelectedValue = '<%# Bind("Nationality") %>' Width="125px" ForeColor="#000099" AppendDataBoundItems="True">
                                            <asp:ListItem Selected="True" Value="">-----------------------</asp:ListItem>
                                        </asp:DropDownList>
                                    </td>

                                   <td style="width:85px">CMND</td>
                                    <td style="width:125px">
                                        <asp:TextBox ID="IDCardTextBox" runat="server" Text='<%# Bind("IDCard") %>' Width="95%" ForeColor="#000099" />
                                    </td>     
                                </tr>

                                <tr>                                                      
                                    <td style="width:85px">Ngày cấp</td>
                                   <td style="width:125px">
                                        <asp:TextBox ID="IDDateTextBox" runat="server" Text='<%# Bind("IDDate", "{0:MM/dd/yyyy}")%>' 
                                            Width="95%" ForeColor="#000099"/>
                                        <cc1:CalendarExtender ID="IDDateTextBox_CalendarExtender" runat="server" BehaviorID="IDDateTextBox_CalendarExtender" 
                                            TargetControlID="IDDateTextBox" Format="MM/dd/yyyy" />                                    
                                    </td>

                                    <td style="width:85px">Nơi cấp</td>                                   
                                    <td style="width:125px">
                                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("IDProvideBy") %>' Width="95%" ForeColor="#000099" />
                                    </td>  
                                </tr>

                                <tr>
                                    <td style="width:85px">SMS</td>
                                    <td style="width:125px">
                                        <asp:DropDownList ID="BASMSStatusDropDownList" runat="server" DataSourceID="sdsBASMSStatus" DataTextField="Name" 
                                            DataValueField="Code" SelectedValue = '<%# Bind("Status") %>' Width="125px" ForeColor="#000099" AppendDataBoundItems="True">
                                            <asp:ListItem Selected="True" Value="">-----------------------</asp:ListItem>
                                        </asp:DropDownList>
                                    </td>                            
                                    <td style="width:85px">Tình trạng</td>
                                    <td style="width:125px">                                        
                                      <asp:DropDownList ID="BAStatusDropDownList" runat="server" DataSourceID="sdsBAStatus" DataTextField="Name" 
                                            DataValueField="Code" SelectedValue = '<%# Bind("BAStatus") %>' Width="125px" ForeColor="#000099" AppendDataBoundItems="True">
                                            <asp:ListItem Selected="True" Value="">-----------------------</asp:ListItem>
                                        </asp:DropDownList>
                                    </td>
                                </tr>

                                <tr>
                                    <td style="width:85px">Ngày vào</td>
                                    <td style="width:125px">
                                        <asp:TextBox ID="InDateTextBox" runat="server" Text='<%# Bind("InDate", "{0:MM/dd/yyyy}")%>' 
                                            Width="95%" ForeColor="#000099"/>
                                        <cc1:CalendarExtender ID="InDateTextBox_CalendarExtender" runat="server" BehaviorID="InDateTextBox_CalendarExtender" 
                                            TargetControlID="InDateTextBox" Format="MM/dd/yyyy" />  
                                    </td>                            
                                    <td style="width:85px">Ngày ra</td>
                                    <td style="width:125px">                                    
                                        <asp:TextBox ID="OutDateTextBox" runat="server" Text='<%# Bind("OutDate", "{0:MM/dd/yyyy}")%>' 
                                            Width="95%" ForeColor="#000099"/>
                                        <cc1:CalendarExtender ID="OutDateTextBox_CalendarExtender" runat="server" BehaviorID="OutDateTextBox_CalendarExtender" 
                                            TargetControlID="OutDateTextBox" Format="MM/dd/yyyy" />
                                    </td>
                                </tr>

                                <tr>
                                    <td style="width:85px">B.đầu HĐ</td>
                                    <td style="width:125px">
                                        <asp:TextBox ID="StartContractDateTextBox" runat="server" Text='<%# Bind("StartContractDate", "{0:MM/dd/yyyy}")%>' 
                                            Width="95%" ForeColor="#000099"/>
                                        <cc1:CalendarExtender ID="StartContractDateTextBox_CalendarExtender" runat="server" BehaviorID="StartContractDateTextBox_CalendarExtender" 
                                            TargetControlID="StartContractDateTextBox" Format="MM/dd/yyyy" />                                    
                                    </td>                            
                                    <td style="width:85px">K.thúc HĐ</td>
                                    <td style="width:125px">
                                        <asp:TextBox ID="EndContractDateTextBox" runat="server" Text='<%# Bind("EndContractDate", "{0:MM/dd/yyyy}")%>' 
                                            Width="95%" ForeColor="#000099"/>
                                        <cc1:CalendarExtender ID="EndContractDateTextBox_CalendarExtender" runat="server" BehaviorID="EndContractDateTextBox_CalendarExtender" 
                                            TargetControlID="EndContractDateTextBox" Format="MM/dd/yyyy" />                                    
                                    </td>
                                </tr>                               

                                <tr>  
                                     <td style="width:85px">Loại HĐ</td>
                                    <td style="width:125px">                                        
                                        <asp:DropDownList ID="ContractTypeDropDownList" runat="server" DataSourceID="sdsContractType" DataTextField="Name" 
                                            DataValueField="Code" SelectedValue = '<%# Bind("ContractType") %>' Width="125px" ForeColor="#000099" AppendDataBoundItems="True">
                                            <asp:ListItem Selected="True" Value="">-----------------------</asp:ListItem>
                                        </asp:DropDownList>
                                    </td>                                  
                                    <td style="width:85px">Số TK</td>
                                    <td style="width:125px">
                                        <asp:TextBox ID="AccountNumberTextBox" runat="server" Text='<%# Bind("AccountNumber") %>' Width="95%" ForeColor="#000099" />
                                    </td>
                                </tr>
                                
                                <tr>                                
                                    <td style="width:85px">Ng.hàng</td>
                                    <td style="width:350px" colspan="3">
                                        <asp:TextBox ID="BankTextBox" runat="server" Text='<%# Bind("Bank") %>' Width="98.5%" ForeColor="#000099" />
                                    </td>                               
                                </tr>

                                <tr>
                                    <td style="width:85px">Giờ làm</td>
                                    <td style="width:125px">                                       
                                        <asp:DropDownList ID="WorkingHourDropDownList" runat="server" DataSourceID="sdsWorkingHour" DataTextField="Name" 
                                            DataValueField="Code" SelectedValue = '<%# Bind("WorkingHour") %>' Width="125px" ForeColor="#000099" AppendDataBoundItems="True">
                                            <asp:ListItem Selected="True" Value="">-----------------------</asp:ListItem>
                                        </asp:DropDownList>
                                    </td>    

                                    <td style="width:85px">Ngày nghỉ</td>
                                    <td style="width:125px">                                        
                                        <asp:DropDownList ID="DayOffDropDownList" runat="server" DataSourceID="sdsWeekDay" DataTextField="Name" 
                                            DataValueField="Code" SelectedValue = '<%# Bind("DayOff") %>' Width="125px" ForeColor="#000099" AppendDataBoundItems="True">
                                            <asp:ListItem Selected="True" Value="">-----------------------</asp:ListItem>
                                        </asp:DropDownList>
                                    </td>                                
                                </tr> 
                                    
                                <tr>                                
                                    <td style="width:85px">Ghi chú</td>
                                    <td style="width:350px" colspan="3">
                                        <asp:TextBox ID="NoteTextBox" runat="server" Text='<%# Bind("Note") %>' Width="98.5%" ForeColor="#000099" />
                                    </td>                               
                                </tr>                               
                                
                                <tr><td style="width:100%; height:10px" colspan="4"></td></tr>
                                <tr>
                                    <td style="width:100%" colspan="4">
                                        <asp:GridView ID="gvCustomer" runat="server" AutoGenerateColumns="false" DataSourceID="sdsBAOutlet" DataKeyNames="Code">
                                            <Columns>
                                                <asp:BoundField DataField="BACode" HeaderText="BACode" ReadOnly="True" Visible ="false"/>
                                                <asp:BoundField DataField="Code" HeaderText="SMS" ReadOnly="True" ItemStyle-Width="60px"/>
                                                <asp:BoundField DataField="DragonCode" HeaderText="Dragon" ItemStyle-Width="70px"/>
                                                <asp:BoundField DataField="Name" HeaderText="Điểm bán" ReadOnly="True" ItemStyle-Width="150px"/>                                                
                                                <asp:BoundField DataField="CVTCSR" HeaderText="SR" ReadOnly="True" ItemStyle-Width="150px"/>                                                
                                            </Columns>
                                            <EmptyDataTemplate>
                                                Nhân viên không được gán điểm bán nào cả!
                                            </EmptyDataTemplate>
                                        </asp:GridView>
                                    </td>
                                </tr>                                    
                                
                                <tr><td style="width:100%; height:10px;" colspan="4"></td></tr>
                                <tr>
                                    <td colspan="4">
                                        <asp:LinkButton ID="UpdateButton" runat="server" style="text-align:center" Width="100%" Font-Bold="True" Font-Size="Larger" 
                                            ForeColor="#000099" CausesValidation="True" CommandName="Update" Text="Cập nhât"  />
                                    </td>    
                                </tr>                            
                            </EditItemTemplate>                                
                            </asp:FormView>
                        </ContentTemplate>
                        </asp:UpdatePanel>                         
                    </td> 
                </tr>               
            </table>                          
        </div> 
      
        <asp:SqlDataSource ID="sdsBAList" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
            SelectCommand="sp_Display_BA_List" SelectCommandType="StoredProcedure" OnSelected="sdsBAList_Selected">
            <SelectParameters>
                <asp:ControlParameter ControlID="ddlProvince" DefaultValue="0" Name="ProvinceCode" PropertyName="SelectedValue" Type="String" />
                <asp:ControlParameter ControlID="ddlBAS" DefaultValue="0" Name="BASCode" PropertyName="SelectedValue" Type="String" />
                <asp:ControlParameter ControlID="ddlBAGroup" DefaultValue="0" Name="BAGroupCode" PropertyName="SelectedValue" Type="Byte" />
                <asp:ControlParameter ControlID="ddlBAStatus" DefaultValue="0" Name="BAStatusCode" PropertyName="SelectedValue" Type="Byte" />
                <asp:ControlParameter ControlID="ddlSMSStatus" DefaultValue="0" Name="BASMSStatusCode" PropertyName="SelectedValue" Type="Byte" />
                <asp:Parameter DefaultValue="|" Name="ProvinceName" Type="String" />
                <asp:Parameter DefaultValue="|" Name="BASName" Type="String" />
                <asp:Parameter DefaultValue="|" Name="CodeNS" Type="String" />
                <asp:Parameter DefaultValue="|" Name="BAName" Type="String" />
                <asp:Parameter DefaultValue="|" Name="Phone" Type="String" />
                <asp:Parameter DefaultValue="|" Name="BAGroupName" Type="String" />
                <asp:Parameter DefaultValue="|" Name="BAStatusName" Type="String" />
                <asp:Parameter DefaultValue="|" Name="CustomerName" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>

        <asp:SqlDataSource ID="sdsBADetail" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
            SelectCommand="SELECT * FROM [BA] WHERE ([Code] = @Code)" OldValuesParameterFormatString="original_{0}" DeleteCommand="DELETE FROM [BA] WHERE [Code] = @original_Code" InsertCommand="INSERT INTO [BA] ([Code], [CodeNS], [Name], [Phone], [BAS], [Status], [BAGroup], [ProfileStatus], [TaxCode], [DOB], [Folk], [Nationality], [ResidentAddress], [IDCard], [IDDate], [IDProvideBy], [BAStatus], [InDate], [OutDate], [StartContractDate], [EndContractDate], [ContractType], [AccountNumber], [Bank], [Brand], [WorkingHour], [DayOff], [Note]) VALUES (@Code, @CodeNS, @Name, @Phone, @BAS, @Status, @BAGroup, @ProfileStatus, @TaxCode, @DOB, @Folk, @Nationality, @ResidentAddress, @IDCard, @IDDate, @IDProvideBy, @BAStatus, @InDate, @OutDate, @StartContractDate, @EndContractDate, @ContractType, @AccountNumber, @Bank, @Brand, @WorkingHour, @DayOff, @Note)" UpdateCommand="UPDATE [BA] SET [CodeNS] = @CodeNS, [Name] = @Name, [Phone] = @Phone, [BAS] = @BAS, [Status] = @Status, [BAGroup] = @BAGroup, [ProfileStatus] = @ProfileStatus, [TaxCode] = @TaxCode, [DOB] = @DOB, [Folk] = @Folk, [Nationality] = @Nationality, [ResidentAddress] = @ResidentAddress, [IDCard] = @IDCard, [IDDate] = @IDDate, [IDProvideBy] = @IDProvideBy, [BAStatus] = @BAStatus, [InDate] = @InDate, [OutDate] = @OutDate, [StartContractDate] = @StartContractDate, [EndContractDate] = @EndContractDate, [ContractType] = @ContractType, [AccountNumber] = @AccountNumber, [Bank] = @Bank, [Brand] = @Brand, [WorkingHour] = @WorkingHour, [DayOff] = @DayOff, [Note] = @Note WHERE [Code] = @original_Code">                       
            <DeleteParameters>
                <asp:Parameter Name="original_Code" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="Code" Type="Int32" />
                <asp:Parameter Name="CodeNS" Type="String" />
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Phone" Type="String" />
                <asp:Parameter Name="BAS" Type="String" />
                <asp:Parameter Name="Status" Type="Byte" />
                <asp:Parameter Name="BAGroup" Type="Byte" />
                <asp:Parameter Name="ProfileStatus" Type="Byte" />
                <asp:Parameter Name="TaxCode" Type="String" />
                <asp:Parameter DbType="Date" Name="DOB" />
                <asp:Parameter Name="Folk" Type="Byte" />
                <asp:Parameter Name="Nationality" Type="Byte" />
                <asp:Parameter Name="ResidentAddress" Type="String" />
                <asp:Parameter Name="IDCard" Type="String" />
                <asp:Parameter DbType="Date" Name="IDDate" />
                <asp:Parameter Name="IDProvideBy" Type="String" />
                <asp:Parameter Name="BAStatus" Type="Byte" />
                <asp:Parameter DbType="Date" Name="InDate" />
                <asp:Parameter DbType="Date" Name="OutDate" />
                <asp:Parameter DbType="Date" Name="StartContractDate" />
                <asp:Parameter DbType="Date" Name="EndContractDate" />
                <asp:Parameter Name="ContractType" Type="Byte" />
                <asp:Parameter Name="AccountNumber" Type="String" />
                <asp:Parameter Name="Bank" Type="String" />
                <asp:Parameter Name="Brand" Type="Byte" />
                <asp:Parameter Name="WorkingHour" Type="Byte" />
                <asp:Parameter Name="DayOff" Type="Byte" />
                <asp:Parameter Name="Note" Type="String" />
            </InsertParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="GridView1" Name="Code" PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="CodeNS" Type="String" />
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Phone" Type="String" />
                <asp:Parameter Name="BAS" Type="String" />
                <asp:Parameter Name="Status" Type="Byte" />
                <asp:Parameter Name="BAGroup" Type="Byte" />
                <asp:Parameter Name="ProfileStatus" Type="Byte" />
                <asp:Parameter Name="TaxCode" Type="String" />
                <asp:Parameter DbType="Date" Name="DOB" />
                <asp:Parameter Name="Folk" Type="Byte" />
                <asp:Parameter Name="Nationality" Type="Byte" />
                <asp:Parameter Name="ResidentAddress" Type="String" />
                <asp:Parameter Name="IDCard" Type="String" />
                <asp:Parameter DbType="Date" Name="IDDate" />
                <asp:Parameter Name="IDProvideBy" Type="String" />
                <asp:Parameter Name="BAStatus" Type="Byte" />
                <asp:Parameter DbType="Date" Name="InDate" />
                <asp:Parameter DbType="Date" Name="OutDate" />
                <asp:Parameter DbType="Date" Name="StartContractDate" />
                <asp:Parameter DbType="Date" Name="EndContractDate" />
                <asp:Parameter Name="ContractType" Type="Byte" />
                <asp:Parameter Name="AccountNumber" Type="String" />
                <asp:Parameter Name="Bank" Type="String" />
                <asp:Parameter Name="Brand" Type="Byte" />
                <asp:Parameter Name="WorkingHour" Type="Byte" />
                <asp:Parameter Name="DayOff" Type="Byte" />
                <asp:Parameter Name="Note" Type="String" />
                <asp:Parameter Name="original_Code" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
            
        <asp:SqlDataSource ID="sdsBAOutlet" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
            SelectCommand="SELECT * FROM [vwBAOutlet] WHERE ([BACode] = @BACode)">
            <SelectParameters>
                <asp:ControlParameter ControlID="GridView1" Name="BACode" PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>            
        </asp:SqlDataSource>
            
        <asp:SqlDataSource ID="sdsProvince" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
            SelectCommand="SELECT * FROM [Province] WHERE ([Status] = @Status)">
            <SelectParameters>
                <asp:Parameter DefaultValue="1" Name="Status" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>    
            
        <asp:SqlDataSource ID="sdsProvinceAll" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
            SelectCommand="SELECT * FROM [Province] ORDER BY [Code]">
        </asp:SqlDataSource>   
         
        <asp:SqlDataSource ID="sdsBAS" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
            SelectCommand="SELECT * FROM [BAS] WHERE ([Province] = @Province)">
            <SelectParameters>
                <asp:ControlParameter ControlID="ddlProvince" Name="Province" PropertyName="SelectedValue" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>    

        <asp:SqlDataSource ID="sdsBASAll" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
            SelectCommand="SELECT * FROM [BAS]">
        </asp:SqlDataSource>    

        <asp:SqlDataSource ID="sdsBAGroup" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
            SelectCommand="SELECT * FROM [BAGroup]">
        </asp:SqlDataSource> 
           
        <asp:SqlDataSource ID="sdsBAStatus" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
            SelectCommand="SELECT * FROM [BAStatus]">
        </asp:SqlDataSource>   
         
        <asp:SqlDataSource ID="sdsBASMSStatus" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
            SelectCommand="SELECT * FROM [BASMSStatus]">
        </asp:SqlDataSource>    
            
        <asp:SqlDataSource ID="sdsProfileStatus" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
            SelectCommand="SELECT * FROM [ProfileStatus]">
        </asp:SqlDataSource> 
               
        <asp:SqlDataSource ID="sdsFolk" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
            SelectCommand="SELECT * FROM [Folk]">
        </asp:SqlDataSource>   
             
        <asp:SqlDataSource ID="sdsNationality" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
            SelectCommand="SELECT * FROM [Nationality]">
        </asp:SqlDataSource> 
               
        <asp:SqlDataSource ID="sdsContractType" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
            SelectCommand="SELECT * FROM [ContractType]">
        </asp:SqlDataSource>  
              
        <asp:SqlDataSource ID="sdsBrand" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
            SelectCommand="SELECT * FROM [Brand]">
        </asp:SqlDataSource>  
              
        <asp:SqlDataSource ID="sdsWorkingHour" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
            SelectCommand="SELECT * FROM [WorkingHour]">
        </asp:SqlDataSource>

        <asp:SqlDataSource ID="sdsWeekDay" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
            SelectCommand="SELECT * FROM [WeekDay]">
        </asp:SqlDataSource>        
            
        <asp:SqlDataSource ID="sdsSMSPeriod" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" 
            SelectCommand="sp_Display_SMS_Period" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:ControlParameter ControlID="GridView1" Name="Code" PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
            
    </form>
</body>
</html>
